package com.tuanzi.loan.web.lazy.statistics;

import com.tuanzi.loan.core.lazy.BaseLazyDataModel;
import com.tuanzi.loan.core.util.SpringContextHolder;
import com.tuanzi.loan.core.vo.PageSearcher;
import org.springframework.data.domain.Page;

import com.tuanzi.loan.vo.request.statistics.ActivityParticipateStatSearchRequest;
import com.tuanzi.loan.vo.response.statistics.ActivityParticipateStatSearchResponse;
import com.tuanzi.loan.business.service.statistics.ActivityParticipateStatService;
import org.springframework.data.domain.PageImpl;

import java.util.Collections;

/**
 * 活动参与统计 DataModel
 * @author JinRuiyang 2018/1/26 10:35:38
 */
public class ActivityParticipateStatDataModel extends
        BaseLazyDataModel<ActivityParticipateStatSearchRequest, ActivityParticipateStatSearchResponse> {
    private Boolean isFirst = true;

    private ActivityParticipateStatService activityparticipatestatService = SpringContextHolder.getBean(ActivityParticipateStatService.class);

    public ActivityParticipateStatDataModel(ActivityParticipateStatSearchRequest searchRequest) {
        super(searchRequest);
    }

    @Override
    protected Page<ActivityParticipateStatSearchResponse> doLoad(PageSearcher<ActivityParticipateStatSearchRequest> pageSearcher) {
        if (isFirst){
            isFirst = false;
            return new PageImpl<>(Collections.emptyList());
        }
        return activityparticipatestatService.list(pageSearcher);
    }
}
